package com.library.recommendation.dao;

import com.framework.BaseDao;
import com.library.entity.Recommendation;
import com.library.entity.Staff;
import org.springframework.stereotype.Repository;

@Repository
public class RecommendationDaoImpl extends BaseDao<Recommendation,String> {

	public Recommendation findByStaff(Staff staff){
		try{
			return super.findOne("from Recommendation r where r.staff=?", new Object[]{staff});
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}

	public Recommendation getRecommendationById(Integer recommendationId){
		try{
			return super.get(recommendationId);
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}


	public void saveRecommendation(Recommendation recommendation){
		try {
			this.save(recommendation);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updateRecommendation(Recommendation recommendation){
		try {
			this.update(recommendation);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteRecommendation(Recommendation recommendation){
		try {
			this.delete(recommendation);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
